import { TipsErrorModalNew } from '@/components/TipsErrorModalNew';
import { handleRemoveService } from './services';
import { message } from 'antd';

export const RemoveModal = ({
  resObj,
  revokeRequestUrl,
  onClose,
  reqBody = {},
  modalTip,
  reloadRequest,
  modalTitle = '提示',
  bodyWidth,
}: Record<string, any>) => {
  const handleRemoveCallback = (res) => {
    if (res?.msgFlag) {
      message?.success(res?.msg);
      reloadRequest();
    }
  };

  const { handleRemoveRun, handleRemoveLoading } = handleRemoveService(handleRemoveCallback, revokeRequestUrl);

  return (
    <TipsErrorModalNew
      onClose={onClose}
      modalTitle={modalTitle}
      modalOnOK={() => {
        const reqParams: Record<string, any> = {
          id: resObj?.id,
          ...reqBody,
        };
        handleRemoveRun(reqParams);
      }}
      modalLoading={handleRemoveLoading}
      bodyWidth={bodyWidth}
      modalTip={modalTip}
    />
  );
};
